package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import com.sc.nft.entity.MallOrderProduct;
import com.sc.nft.mapper.MallOrderProductMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * ip商品订单关联商品表(sc_mall_order_product)数据DAO
 *
 * @author Sun
 * @since 2023-05-09 10:47:10
 * @description 由 Mybatisplus Code Generator 创建
 */
@Slf4j
@Repository
public class MallOrderProductDao extends ServiceImpl<MallOrderProductMapper, MallOrderProduct> {

    public List<MallOrderProduct> getListByOrderId(Long orderId) {
        LambdaQueryWrapper<MallOrderProduct> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(MallOrderProduct::getMallOrderId, orderId);
        return list(wrapper);
    }

    public MallOrderProduct getOneByOrderIdAndOrderProductId(Long orderId, Long id) {
        LambdaQueryWrapper<MallOrderProduct> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(MallOrderProduct::getMallOrderId, orderId);
        wrapper.eq(MallOrderProduct::getId, id);
        return getOne(wrapper);
    }
    public MallOrderProduct getByOrderId(Long orderId) {
        LambdaQueryWrapper<MallOrderProduct> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(MallOrderProduct::getMallOrderId, orderId);
        return getOne(wrapper);
    }
}